package cn.threewaters.qtyy.web.controller.business;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.baomidou.mybatisplus.plugins.Page;

import cn.threewaters.qtyy.common.bean.PageBean;
import cn.threewaters.qtyy.common.bean.ResponseJson;
import cn.threewaters.qtyy.dic.one.queryparam.QueryCfpz;
import cn.threewaters.qtyy.dic.one.queryresult.ResultCfpz;
import cn.threewaters.qtyy.service.business.CfpzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

@Api(tags = "仓房配置")
@Controller
@RequestMapping(value = "/cfpz")
public class CfpzController {
	
	@Autowired
	private CfpzService cfpzService;

	@ApiIgnore
	@ApiOperation(value = "仓房配置展示页面")
	@RequestMapping(value = "/main", method = RequestMethod.GET)
	public ModelAndView main(ModelMap modelMap) {
		return new ModelAndView("business/cfpz/cfpz", modelMap);
	}

//	@ApiIgnore
//	@ApiOperation(value = "仓房配置新增页面")
//	@RequestMapping(value = "/add/view", method = RequestMethod.GET)
//	public ModelAndView addView(ModelMap modelMap) {
//		return new ModelAndView("business/cfpz/cfpz_add");
//	}
//
//	@ApiIgnore
//	@ApiOperation(value = "仓房配置修改页面")
//	@RequestMapping(value = "/update/view/{id}", method = RequestMethod.GET)
//	public ModelAndView updateView(@PathVariable(value = "id") String id, ModelMap modelMap) {
//		return new ModelAndView("business/cfpz/cfpz_update", modelMap);
//	}

	@ApiOperation(value = "仓房配置列表")
	@RequestMapping(value = "/cfpzLB", method = RequestMethod.GET)
	@ResponseBody
	public ResponseJson getList(PageBean page,QueryCfpz queryCfpz) throws Exception {
		Page<ResultCfpz> pageResult = new Page<ResultCfpz>();
		List<ResultCfpz> cfpzLBs = cfpzService.queryCfpzLB(queryCfpz);
		pageResult.setRecords(cfpzLBs);
		pageResult.setTotal(cfpzLBs.size());
		return ResponseJson.builder().success(true).obj(pageResult).build();
	}

}
